package com.atwulidun.composite08;

import java.util.ArrayList;
import java.util.List;

public class College extends OrganizationComponent {
    // 聚合系
    private List<OrganizationComponent> departments = new ArrayList<>();

    public College(String name, String des) {
        super(name, des);
    }

    // 增加系方法
    @Override
    protected void add(OrganizationComponent organizationComponent) {
        departments.add(organizationComponent);
    }

    // 删除系方法
    @Override
    protected void remove(OrganizationComponent organizationComponent) {
        departments.remove(organizationComponent);
    }

    // 打印当前学院以及所包含系方法
    @Override
    protected void print() {
        System.out.println("-----------------" + getName() + "------------------");
        for (OrganizationComponent department : departments) {
            department.print();
        }
    }
}
